//
//  JHMiddleWordDownloadController.m
//  JuniRengLish_iOS
//
//  Created by 邓建 on 2019/5/8.
//  Copyright © 2019 revogi. All rights reserved.
//

#import "JHMiddleWordDownloadController.h"
#import "JHMiddleWordDownloadCell.h"
#import "JHBookDataListView.h"

//标志符
static NSString * const cellID = @"JHMiddleWordDownloadCell";

@interface JHMiddleWordDownloadController ()

@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSArray *dataArray;
@property (nonatomic, strong) JHBookDataListView * listView;

@end

@implementation JHMiddleWordDownloadController

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self initNav];
    
    UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 44)];
    titleLabel.text = @"单词";
    titleLabel.textColor = [UIColor darkTextColor];
    titleLabel.font = [UIFont systemFontOfSize:17];
    self.navigationItem.titleView = titleLabel;
    self.dataArray = [NSMutableArray array];

    [self.view addSubview:self.listView];
}

- (void)initNav
{
    self.navigationItem.rightBarButtonItem=[UIBarButtonItem itemWithBackIconImage:@"删除" setBackTitle:nil target:self action:@selector(allDownLoadBtn:)];
}

#pragma mark---- 删除
- (void)allDownLoadBtn:(UIBarButtonItem *)item
{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"deleteWordUnitAllData" object:@"word"];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    [self.navigationController.navigationBar setBackgroundImage:[DJTool imageWithColor:[UIColor whiteColor]] forBarMetrics:UIBarMetricsDefault];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"背景1"] forBarMetrics:UIBarMetricsDefault];
}

- (JHBookDataListView *)listView
{
    if (!_listView)
    {
        _listView = [[JHBookDataListView alloc] initWithFrame:CGRectMake(0, 0, JKScreenW, JKScreenH - kStatusBarAndNavigationBarHeight - kTabbarSafeBottomMargin)];
        _listView.currentVC = self;
        _listView.isBook = NO;
        _listView.requestUrl = self.dataModel.jsonfileurl;
    }
    return _listView;
}

@end
